
const { flowRight } = require("lodash")

const reverse = arr => arr.reverse()
const first = arr => arr[0]
const toUpper = arr => arr.toUpperCase()

// const fn = flowRight(toUpper, first, reverse)

const arr = ['aa', 'bb', 'cc', 'dd']

// console.log(fn(arr))

// const _flowRight = (...args) => {
//     return (val) => {
//         return args.reverse().reduce((res, fn) => {
//             console.log(res)
//             return fn(res)
//         }, val)
//     }
// }

const _flowRight = (...args) => val => args.reverse().reduce((res, fn) => fn(res), val)

const my_fn = _flowRight(toUpper, first, reverse)

const my_fn1 = _flowRight(_flowRight(toUpper, first), reverse)

// console.log(my_fn(arr))
console.log(my_fn1(arr))